using System;
using System.Text;
using System.Configuration;

namespace SystemFrameworks.Util
{
	/// <summary>
	/// Summary description for DecimalHelp.
	/// </summary>
	public class DecimalHelp
	{
	
		private DecimalHelp()
		{
		}

		/// <summary>
		/// Format Decimal with "0.0", "0.00", "0.00..0" and so on
		/// </summary>
		/// <param name="dec"></param>
		/// <param name="tailCount"></param>
		/// <returns></returns>
		public static string Format( decimal dec, int tailCount )
		{
			if ( tailCount < 0 )
			{
				return dec.ToString();
			}
			else
			{
				StringBuilder sb = new StringBuilder( "0" );
				if ( tailCount > 0 )
				{
					sb.Append( "." );
					for ( int i = 0; i < tailCount; i++ )
					{
						sb.Append( "0" );
					}
				}
				return dec.ToString( sb.ToString() );
			}
		}
	}
}
